<!--
 * @Descripttion: 
 * @Author: voanit
 * @Date: 2022-06-10 15:57:30
 * @LastEditors: voanit
 * @LastEditTime: 2022-06-10 17:15:54
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.1.2/jquery.min.js"></script>
  <!-- <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script> -->
  <!-- <script src="https://cdn.bootcdn.net/ajax/libs/fullPage.js/4.0.9/fullpage.js"></script> -->
  <script src="https://cdn.bootcdn.net/ajax/libs/fullPage.js/3.0.4/fullpage.js"></script>
  <link rel="stylesheet" href="./index.css">
</head>

<body>
  <div class="box">
    <div class="music">
      <!-- 暂停 -->
      <img class="pause" style="display:block" src="https://qnm.hunliji.com/o_1fd75pfpo1s201tscp8q1s5376t18.png" alt="">
      <!-- 播放 -->
      <img class="play" style="display:none" src="https://qnm.hunliji.com/o_1fd75p67b10u018qdpac19drglgu.png" alt="">
    </div>
    <!-- <audio autoplay loop muted>
      <source src="./real-love.mp3" type="audio/ogg">
    </audio> -->
    <audio autoplay loop src="./real-love.mp3"></audio>
  </div>
  <div id="fullpage">
    <div class="section section1 ">
      <h1>刘义赞</h1>
      <h2>张嘉文</h2>
      <h3>王游游</h3>
    </div>
    <div class="section">第二屏</div>
    <div class="section">
      <div class="slide">第三屏的第一屏</div>
      <div class="slide">第三屏的第二屏</div>
      <div class="slide">第三屏的第三屏</div>
      <div class="slide">第三屏的第四屏</div>
    </div>
    <div class="section">第四屏</div>
  </div>

  <script>
    $(function () {
      let iframe = document.createElement('iframe');
      iframe.src = "./real-love.mp3";
      document.body.appendChild(iframe);
      /* 初始化代码 */
      $('#fullpage').fullpage({
        sectionsColor: ["red", "green", "blue"],
        navigation: true,
        navigationColor: '#333',
        navigationPosition: 'right',
        afterLoad: function (anchorLink, { index }) {
          console.log(index);
          if (index === 0) {
            document.querySelector('.section1').setAttribute('class', 'section section1 active1')
            // $('.section1 h1').css('transform', 'none')
            const audio = document.querySelector('audio')
            console.log(audio, 9);
            // audio.play()
            // if (audio.paused) {
            //   setTimeout(() => {
            //     audio.play()
            //   }, 2000)
            // }

          }
        }
      });

      // music
      document.querySelector('.box .music').onclick = function () {
        const audio = document.querySelector('audio')
        if (audio.paused) {
          audio.play()
          this.querySelector('.pause').style.display = 'none'
          this.querySelector('.play').style.display = 'block'
          document.querySelector('.play').setAttribute('class', 'play playActive')
        } else {
          audio.pause()
          this.querySelector('.pause').style.display = 'block'
          this.querySelector('.play').style.display = 'none'
          document.querySelector('.play').setAttribute('class', 'play')
        }
      }
    });
  </script>
</body>

</html>